package com.harmonk.firstscene

import android.app.Application
import androidx.appcompat.app.AppCompatDelegate
import com.harmonk.firstscene.constants.CommonConstants
import com.harmonk.firstscene.db.AppDatabase
import com.harmonk.firstscene.db.repository.*
import com.harmonk.firstscene.db.repository.EventWithAllRepository

class FirstSceneApplication : Application() {
    private val database by lazy { AppDatabase.getDatabase(this) }

    val trafficEventRepository by lazy {
        TrafficEventRepository(
            database.trafficEventDao(),
        )
    }

    val vehicleRepository: VehicleRepository by lazy {
        VehicleRepository(database.vehicleDao())
    }

    val personRepository: PersonRepository by lazy {
        PersonRepository(database.personDao())
    }

    val eventNoteRepository: EventNoteRepository by lazy {
        EventNoteRepository(database.trafficNoteDao())
    }

    val quickNoteRepository: QuickNoteRepository by lazy {
        QuickNoteRepository(database.quickNoteDao())
    }

    val roadRepository: RoadRepository by lazy {
        RoadRepository(database.roadDao())
    }

    val eventWithAllRepository by lazy {
        EventWithAllRepository(
            database.trafficEventDao(),
            database.vehicleDao(),
            database.personDao(),
            database.trafficNoteDao()
        )
    }

    override fun onCreate() {
        super.onCreate()
        // 应用启动时的初始化代码可以放在这里
    }
}